<!-- Teacher_DailyNoReviewedFrameDetail_Frame.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>日报详情页</title>
		<script src="../../script/mui.min.js"></script>
		<script src="../../script/jquery.min.js" type="text/javascript"></script>
		<script src="../../script/timecontrol.min.js"></script>
		<script src="../../script/common.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/timecontrol.min.css" />
		<!--<link rel="stylesheet" href="../../css/CFNetPP_Base.css">-->
		<link rel="stylesheet" href="../../css/base.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css">
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
		<style>
			.feeling .feeling-text {
				text-indent: 2em;
				background-size: 16px;
				margin-top: 15px;
				margin-top: 15px;
				margin-right: 10px;
				margin-bottom: 10px;
				margin-left: -5px;
			}
		</style>
	</head>
	<body>
		<div class="writeReport" id="all_div">
			<div class="ReviewWeekly_div top_54" >
				<ul class="mui-table-view">
					<li class="mui-table-view-cell base_dark_grey" id="timediv_one" style="display: none">
						<div class="cell_left_img_div">
							<img class="cell_img" src="../../image/icon_clock.png" alt="">
						</div>
						<span class="time_span base_title_font" > 应交日期:</span>
						<span class="time_span base_title_font" id="nomal_time"> </span>
					</li>
					<li class="mui-table-view-cell base_dark_grey" id="timediv_two">
						<div class="cell_left_img_div">
							<img class="cell_img" src="../../image/icon_clock.png" alt="">
						</div>
						<span class="time_span base_title_font" > 提交日期:</span>
						<span class="time_span base_title_font" id="now_time"> </span>
					</li>
				</ul>
			</div>
			<div class="ReviewWeekly_div">
				<div class="feeling">
					<p class="title">
						本日总结
					</p>
					<div class="feeling-text">
						<p id="summary" style=" word-break: break-all"></p>
					</div>
				</div>
			</div>
			<div class="ReviewWeekly_div">
				<p class="title titlepos">
					老师评语
				</p>
				<div class="padding10">
					<textarea class="textarea_t" id="comment"></textarea>
				</div>
			</div>
			<button type="button" id="bt" class="mui-btn mui-btn-warning horcenter btn_submit top_40 bottom_30" onclick="sumbit()">
				提交
			</button>
		</div>
		<div id="offlineAlert" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title">是否放弃在此页面操作？</strong>
				</div>
				<div class="weui_dialog_bd"></div>
				<div class="weui_dialog_ft">
					<a onclick="cleanCancel()" href="#" class="weui_btn_dialog default"  style="color:#18b4ed">取消</a>
					<a onclick="cleanConfirm()" href="#" class="weui_btn_dialog primary"  style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
	</body>
	<script src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/base64.min.js"></script>
	<script type="text/javascript" src="../../script/copyTool.js"></script>
	<script type="text/javascript">
		var sid = 0;
		var commentScore = '';
		var parten = /^\s*$/;
		var dailyid = '';
		var stuid = '';
		apiready = function() {
			// SendBehaviorTrajectoriesNotifi1('0', '老师端批改日报', '103', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title);
			var pageParam = api.pageParam;
			dailyid = pageParam.dailyid;
			stuid = pageParam.stuid;
			loadDailyData();
			judgeiosTypeChange();
			setupNotifi();
			blockAddCopyClickWithIdArr(["summary"]);
		}
		function setupNotifi() {
			api.addEventListener({
				name : 'showDailyAlertNotifi'
			}, function(ret, err) {
				showAlert();
			});
		}

		//获取日报详情数据
		function loadDailyData() {
			var param = {
				dailyid : dailyid //未审核状态的日报列表
			};
			cfnetppPOST(urlLswkinfo, param, false, function(data, status) {
				if (status == 'success') {
					if (data.status == 1) {
						var list = data.json;
						if (list != null) {
							var name = list.rename1;
							api.sendEvent({
								name : 'dailynameNotifi',
								extra : {
									dailyname : name + "的日报"
								}
							});
							var time = parseInt(list.weeklytime);
							var comments = list.comments;
							var weeklytime = getLocalTime(time);
							if (isSameToday(weeklytime, list.time) == true) {
								$('#now_time').text(weeklytime);
								$('#timediv_one').hide();
							} else {
								$('#timediv_one').show();
								$('#now_time').text(getLocalTime(list.time));
								$('#nomal_time').text(weeklytime);
							}
							$('#summary').text(Base64.decode(list.summary));
						} else {
							api.toast({
								msg : '获取数据失败',
								duration : 2000,
								location : 'bottom'
							});
						}
					} else {
						api.toast({
							msg : '获取数据失败',
							duration : 2000,
							location : 'bottom'
						});
					}
				} else {
					api.toast({
						msg : '网络连接失败',
						duration : 2000,
						location : 'bottom'
					});
				}
			});
		}

		//未审核日报老师评价提交
		function sumbit() {
			SendBehaviorTrajectoriesNotifi('1', '老师端批改日报', '103');
			comment = $('#comment').val();
			if (comment.length <= 0 || parten.test(comment)) {
				commentScore = '无评语';
			} else {
				commentScore = comment;
			}
			showProgress();
			var param = {
				jid : $api.getStorage('cfnetppjid'),
				lsid : $api.getStorage('cfnetppuid'),
				uid : $api.getStorage('cfnetppuid'),
				stuid : stuid,
				dailyid : dailyid,
				comments : Base64.encode(commentScore),
				message : api.pageParam.studentname + '的日报'
			};

			cfnetppPOST(urlLsrbevaluate, param, false, function(data, status) {
				hideProgress();
				if (status == 'success') {
					if (data.status == 1) {
						SendBusinessOperationsLogNotifi('老师端批改日报', '103', param, param, '', data, '教师端日报评价接口', '103-01')
						api.toast({
							msg : '提交成功',
							duration : 2000,
							location : 'bottom'
						});
						sendNotifi();
						setTimeout(function() {
							next();
						}, 500);
					} else {
						ShowToast('提交失败，请重试');
					}
				} else {
					ShowToast('提交失败，请重试');
				}
			});
			//			}
		}

		//		function next() {
		//			api.openWin({useWKWebView:true,
		//				name : 'Teacher_DailyWindow',
		//				url : 'Teacher_DailyWindow.html',
		//			});
		//		}
		function backKey() {
			api.addEventListener({
				name : 'keyback'
			}, function(ret, err) {
				showAlert();
			});
		}

		function showAlert() {
			commentScore = $('#comment').val();
			// alert(summary);
			if (commentScore.length > 0) {
				$('#offlineAlert').show();
			} else {
				backClick();
			}
		}

		function cleanCancel() {
			$('#offlineAlert').hide();
		}

		//确定
		function cleanConfirm() {
			$('#offlineAlert').hide();
			backClick();
		}

		//		发送刷新日报已审核通知
		function sendNotifi() {
			api.sendEvent({
				name : 'RefreshDailyReviewedNotifi'
			});
		}

		function next() {
			api.closeToWin({
				name : 'Teacher_DailyWindow'
			});
		}

		function backClick() {
			api.sendEvent({
				name : 'closeTeacher_DailyNoReviewedFrameDetail_FrameNotifi'
			});
			//如果2秒后未关闭则自动关闭
			setTimeout(function() {
				SendBehaviorTrajectoriesNotifi1('1', '老师端批改日报', '103', api.pageParam.sourceurl, api.pageParam.sourcetitle, window.location.pathname, document.title);
				api.closeWin({
					name : 'Teacher_DailyNoReviewedFrameDetail'
				});
			}, 2000);
		}
	</script>
</html>